﻿using System;
using Echo.Context.UltiProNet.Contexts;
using Echo.Core.TestAbstraction.WebUITest.MbUnit;
using Echo.Models.UltiProNet;
using Echo.Models.UltimateSoftware;
using Echo.Models.UltimateSoftware.WebUITest.MbUnit;
using MbUnit.Framework;
using Echo.Core.Common;

////*************************************************************************************************************************************
////Created by: Jannette Hamilton.
////Date created: May 6, 2013
////Modified by: 
////Date modified: 
////Reason: 
////ULTI-91892 JIRA Description.
////RUN TIME: ~30 mins (3 BROWSERS)
////*************************************************************************************************************************************

namespace Echo.Automation.Compliance.BusinessRules.Locations
{
    [TestFixture]
    [Author("Jannette Hamilton", "Jannette_Hamilton@ultimatesoftware.com")]
    [Category("<Business Rules>")]
    [Header("Config")]
    [Config(".NET")]
    //[Config("IEOnly")]
    //[Config("ChromeOnly")]
    //[Config("FFOnly")]

    public class AddLocationsUS : MbUnitAutomatedTest
    {
        UltiPro UltiPro;
        UltiProDatabaseContext Database;

        [FixtureSetUp]
        public void FixtureSetUp()
        {
            UltiPro = Launch<UltiPro>();
            Database = Init<UltiProDatabaseContext>();
            Database.Company = ConfigDatabase("UltiPro_CALENDAR");
            //Database.Company.AddRollBack("iLocation");
            //Database.Company.AddRollBack("Loccomp");
            Database.Company.AddRollBack("Addresses");
            Database.Company.AddRollBack("PhoneNumbers");
            // Login as System Admin JanH and navigate to  System Admin > Business Rules > Locations
            UltiPro.Pages.Login.LoginAs("JanH", "password", Config.LanguageCode);
            UltiPro.Pages.CompanySelector.ChooseMasterCompany("CALEN");
            UltiPro.Pages.CompanySelector.ChooseComponentCompany("C0014");
        }

        [FixtureTearDown]
        public void FixtureTearDown()
        {
            Database.Company.RollBackDatabase();
            Database.Company.Execute("Delete from Location where LocCode in ('JANPA', 'JANGA', 'JANNM', 'JANALL', 'JANALA', 'JANPA2')");
            Database.Company.Execute("Delete from LocComp where LcpCode in ('JANPA', 'JANGA', 'JANNM', 'JANALL', 'JANALA', 'JANPA2')");
            Database.Company.Execute("Delete from LocalDescriptions where lcdID in ('JANPA', 'JANGA', 'JANNM', 'JANALL', 'JANALA', 'JANPA2')");
            UltiPro.Browser.Quit();
        }

        [SetUp]
        public void SetUp()
        {
            UltiPro.Macros.Navigate.ToBusinessRule("Locations");
        }

        [TearDown]
        public void TearDown()
        {
        }

        #region Helper Functions
        public void SelectLocationCode(string sLocCode)
        {
            UltiPro.Pages.LocationSummary.LocationSummaryGrid.Find(code => code.CodeFilter, FilterType.Is, sLocCode);
            UltiPro.Pages.LocationSummary.LocationSummaryGrid.Row(0).Click(column => column.CodeLink);
        }

        public void SetRequiredFields(string locCountry, string locCode, string locDesc, string trdName, string pLine1, string pCity, string pState, string pZip, string workInStateTaxCode, string locCompany)
        {
            UltiPro.Pages.AddChgLocations.Enabled(countryCombo => countryCombo.LocationCountryDropdown);
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.LocationCountryDropdown, locCountry, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.CodeTextbox, locCode);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.DescriptionTextbox.EnglishTextBox, locDesc);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.TradeNameTextbox.EnglishTextBox, trdName);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressLine1Texbox, pLine1);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressCityTexbox, pCity);
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.PhyicalAddressStateProvinceDropdown, pState, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressZipPostalCodeTexbox, pZip);
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.WorkInStateDropdown, workInStateTaxCode, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Source, locCompany, SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowRight);
        }

        public void SetTaxCodes(string wiCounty, string wiResRate, string wiNonResRate, string occRate, string otherRate)
        {
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInCountyDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInCountyDropdown, wiCounty, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInTaxResidentRateDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInTaxResidentRateDropdown, wiResRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInTaxNonResidentRateDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInTaxNonResidentRateDropdown, wiNonResRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.OccupationalDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.OccupationalDropdown, occRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.OtherDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.OtherDropdown, otherRate, SelectOption.Value);
        }

        public void SetTaxCodesWithNoNonResRate(string wiCounty, string wiResRate, string occRate, string wcRate, string otherRate)
        {
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInCountyDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInCountyDropdown, wiCounty, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInTaxResidentRateDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInTaxResidentRateDropdown, wiResRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.OccupationalDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.OccupationalDropdown, occRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkersCompensationDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkersCompensationDropdown, wcRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.OtherDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.OtherDropdown, otherRate, SelectOption.Value);
        }
        #endregion

        #region GIVEN THAT ONLY THE REQUIRED FIELDS ARE ENTERED, WHEN SAVE IS HIT, THEN A NEW LOCATION IS CREATED (PA). (ENTER REQUIRED FIELDS 1 AT A TIME)
        [Test(Order = 1)]
        public void RequiredFields()
        {
            //DETAILS SECTION
            UltiPro.Pages.LocationSummary.ButtonBar.Click(button => button.Add);
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.LocationCountryDropdown, "USA", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(textbox => textbox.CodeTextbox);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 9 highlighted field(s) before continuing");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.CodeTextbox, "JANPA");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 8 highlighted field(s) before continuing");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.DescriptionTextbox.EnglishTextBox, "JANNETTE PA");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 7 highlighted field(s) before continuing");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.TradeNameTextbox.EnglishTextBox, "JANNETTE PA TRADENAME");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 6 highlighted field(s) before continuing");

            //PHYSICAL ADDRESS SECTION
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressLine1Texbox, "7507 Kimberly Blvd");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 5 highlighted field(s) before continuing");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressCityTexbox, "NORTH LAUDERDALE");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 4 highlighted field(s) before continuing");
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.PhyicalAddressStateProvinceDropdown, "PA", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 3 highlighted field(s) before continuing");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressZipPostalCodeTexbox, "33068");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);

            //TAX INFORMATION SECTION  
            UltiPro.Pages.AddChgLocations.Set(wiDropdown => wiDropdown.WorkInStateDropdown, "PASIT", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 2 highlighted field(s) before continuing");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Please correct the 1 highlighted field(s) before continuing");
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Source, "Web Payroll Company", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowRight);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            System.Threading.Thread.Sleep(4000);

            // WHEN THE CHANGES ARE SAVED, THEN THE DBs ARE UPDATED WITH THE CHANGES
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocGLAcctNo, LocImportCode, LocInactiveDate, LocIsInactive, LocAddressCity, LocAddressCounty, LocAddressLine1, LocAddressLine2, LocAddressLine3, LocAddressLine4, LocAddressState,LocAddressZipcode, LocContactAddressCity, LocContactAddressCountry, LocContactAddressCounty,LocContactAddressLine1, LocContactAddressLine2, LocContactAddressLine3, LocContactAddressLine4, LocContactAddressState, LocContactAddressZipcode, LocBarCode, LocCoBankID, LocContact, LocMailstop, LocPhoneFaxNumber,LocPhoneMainExt, LocPhoneMainNumber, LocPhoneModemNumber, LocReportingCategory, LocReportingUnitNo,LocSUIUnitCode, LocUnitID,LocQEIDCode,LocCMACode, LocPrimaryCommentCode,LocSecondaryCommentCode, LocComments, LocPhoneFaxNumberCountryCode,LocPhoneMainNumberCountryCode, LocPhoneModemNumberCountryCode, LocContractPostSnNoOfGame, LocContractSeasonNoOfGame from location where loccode in ('JANPA') ORDER BY loccode", "LocationBusinessRules/AddLocationsUS_LocJANPA1.xml");
            Database.Company.Verify("SELECT LcpCode, LcpCoID, LcpInactiveDate,LcpIsInactive from loccomp where lcpcode in ('JANPA') order by lcpcode", "LocationBusinessRules/AddLocationsUS_LocCompJANPA1.xml");
        }
        #endregion

        #region GIVEN THAT A LOCATION HAS NO COUNTY OR LOCAL TAXES (GA), WHEN SAVE IS HIT, THEN A NEW LOCATION IS CREATED.
        [Test(Order = 2)]
        public void AddLocWithNoCountyOrLocalTax()
        {
            UltiPro.Pages.LocationSummary.ButtonBar.Click(button => button.Add);
            SetRequiredFields("USA", "JANGA", "Jannette's GA 123*", "Jannette's GA 123* TR", "1 Physical Line1", "PhysicalCity", "GA", "321654987", "GASIT", "Web Payroll Company");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            System.Threading.Thread.Sleep(2000);
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocGLAcctNo, LocImportCode, LocInactiveDate, LocIsInactive, LocAddressCity, LocAddressCounty, LocAddressLine1, LocAddressLine2, LocAddressLine3, LocAddressLine4, LocAddressState,LocAddressZipcode, LocBarCode, LocCoBankID, LocContact, LocMailstop, LocPhoneFaxNumber,LocPhoneMainExt, LocPhoneMainNumber, LocPhoneModemNumber, LocReportingCategory, LocReportingUnitNo,LocSUIUnitCode, LocUnitID, LocPrimaryCommentCode,LocSecondaryCommentCode, LocComments, LocPhoneFaxNumberCountryCode,LocPhoneMainNumberCountryCode, LocPhoneModemNumberCountryCode from location where loccode in ('JANGA') ORDER BY loccode", "LocationBusinessRules/AddLocationsUS_LocJANGA.xml");
        }
        #endregion

        #region GIVEN THAT A LOCATION HAS NO COUNTY, BUT HAS RESIDENT, NON-RESIDENT, & WORKER'S COMP TAXES (NM), WHEN SAVE IS HIT, THEN A NEW LOCATION IS CREATED.
        //ADD TO THREE COMPANIES, 2 SETUP FOR AND THE OTHER NOT. VERIFY THAT A LOC CANNOT BE ADDED WITH A COMPANY THAT IS NOT SETUP FOR THE SELECTED TAXCODE(S).
        [Test(Order = 3)]
        public void AddLocWithNoCountyButHasResAndNonRes()
        {
            UltiPro.Pages.LocationSummary.ButtonBar.Click(button => button.Add);
            SetRequiredFields("USA", "JANNM", "Jannette New Mexico", "Jannette's NM TR", "NM Line1", "NM Physical City", "NM", "32165", "NMSIT", "Web Payroll Company");
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Source, "Web Payroll Two Company", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowRight);
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Source, "US Company", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowRight);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInTaxResidentRateDropdown, "NMWCEE", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInTaxNonResidentRateDropdown, "NMWCEP", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkersCompensationDropdown, "NMWCER", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);

            //VERIFY THAT WHEN THE SELECTED TAXCODE(S) ARE NOT SETUP FOR A COMPANY, THEN THE LOCATION CANNOT BE ADDED
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Tax code \"NMSIT\" not setup for \"US Company\".");
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Tax code \"NMWCEE\" not setup for \"US Company\".");
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Tax code \"NMWCEP\" not setup for \"US Company\".");
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Tax code \"NMWCER\" not setup for \"US Company\".");

            //REMOVE US Company FROM THE SELECTED LIST AND SAVE
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Destination, "US Company", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowLeft);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            System.Threading.Thread.Sleep(2000);

            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocGLAcctNo, LocImportCode, LocInactiveDate, LocIsInactive, LocAddressCity, LocAddressCounty, LocAddressLine1, LocAddressLine2, LocAddressLine3, LocAddressLine4, LocAddressState,LocAddressZipcode from location where loccode in ('JANNM') ORDER BY loccode", "LocationBusinessRules/AddLocationsUS_JANNM.xml");
            Database.Company.Verify("select LcpCode, LcpCoID,CmpCompanyName, LcpInactiveDate,LcpIsInactive from loccomp join company on LcpCoID = CmpCoid where lcpcode  = 'JANNM'  and LcpCoID = 'C0014' order by lcpcode", "LocationBusinessRules/AddLocationsUS_LocCompWebPayroll_JANNM.xml");
            Database.Company.Verify("select LcpCode, LcpCoID,CmpCompanyName, LcpInactiveDate,LcpIsInactive from loccomp join company on LcpCoID = CmpCoid where lcpcode  = 'JANNM'  and LcpCoID = 'XB3CV' order by lcpcode", "LocationBusinessRules/AddLocationsUS_LocCompWebPayroll2_JANNM.xml");
        }
        #endregion

        #region GIVEN THAT A LOCATION HAS ALL FIELDS POPULATED (NJ), WHEN SAVE IS HIT, THEN A NEW LOCATION IS CREATED.
        [Test(Order = 4)] // IN R2 2013 TEST HAS BEEN FAILING ON IE & FF. PASSES ON CHROME & MANUALLY... INVESTIGATE BUT LOOKS LIKE IT'S TIMING OUT ON SAVING DUE TO LARGE AMOUNT OF DATA
        public void AddLocWithAllFields()
        {
            var inactDate = new DateTime(2013, 05, 06);

            #region DETAILS SECTION
            UltiPro.Pages.LocationSummary.ButtonBar.Click(button => button.Add);
            SetRequiredFields("USA", "JANALL", "Jannette All New Jersey", "Jannette's NJ TRADENAME", "NJ Physical Line1", "PhysicalCityNJ", "NJ", "333334444", "NJSIT", "Web Payroll Company");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressCountyTexbox, "CORNWALL");

            // DESCRIPTION
            UltiPro.Pages.AddChgLocations.Click(button => button.DescriptionButton);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.DescriptionTextbox.CanadianEnglishTextBox, "Jannette NJ DESC CAN1");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.DescriptionTextbox.BritishEnglishTextBox, "Jannette NJ DESC GBR*");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.DescriptionTextbox.SpanishTextBox, "Jannette NJ DESC SPN %^$");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.DescriptionTextbox.FrenchTextBox, "Jannette NJ DESC FRN 456");

            // TRADE NAME
            UltiPro.Pages.AddChgLocations.Click(button => button.TradeNameButton);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.TradeNameTextbox.CanadianEnglishTextBox, "JA CAN TRADENAME !@");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.TradeNameTextbox.BritishEnglishTextBox, "JA GBR TRADENAME 12");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.TradeNameTextbox.SpanishTextBox, "JA SPN TRADENAME3");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.TradeNameTextbox.FrenchTextBox, "JA FRN TRADENAME4");
            UltiPro.Pages.AddChgLocations.Click(checkbox => checkbox.InactiveCheckbox);
            UltiPro.Pages.AddChgLocations.InactiveDate.Set(inactDate);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.GlSegmentTextbox, "JANNETTE'S GLS");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ImportCodeTextbox, "JHIMPORTCO");
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.ReportingCategoryDropdown, "LOCUSA", SelectOption.Value);
            #endregion DETAILS SECTION

            #region ADDRESS & CONTACT SECTION
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressLine2Texbox, "Physical Address Line 2");

            //CONTACT INFORMATION
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.ContactCountryDropdown, "CAN", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactAddressLine1Texbox, "5167 NW 87 TERRACE");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactAddressLine2Texbox, "EAGLE RIDGE AT LAUDERHILL");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactCityTexbox, "LAUDERHILL");
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.ContactStateProvinceDropdown, "Nova Scotia", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactZipPostalCodeTexbox, "R7R 5X5");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactCountyTexbox, "TORONTO COUNTY");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactNameTexbox, "JANNETTE GRACE HAMILTON");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.MailstopTexbox, "1stFLR");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.DeliveryBarCodeTextbox, "8*");
            UltiPro.Pages.AddChgLocations.Enabled(textbox => textbox.PhoneNumberTextbox);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhoneNumberTextbox, "954 331 7488");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhoneNumberTextbox, "(954) 331-7488");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ExtensionTextbox, "X7488");
            UltiPro.Pages.AddChgLocations.Enabled(textbox => textbox.FaxNumberTextbox);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.FaxNumberTextbox, "954 331 7688");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.FaxNumberTextbox, "(954) 331-7688");
            UltiPro.Pages.AddChgLocations.Enabled(textbox => textbox.ModemNumberTextbox);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ModemNumberTextbox, "754 551 4112");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ModemNumberTextbox, "(754) 551-4112");
            #endregion ADDRESS & CONTACT SECTION

            #region TAX INFORMATION SECTION
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInTaxResidentRateDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInTaxResidentRateDropdown, "NJ002", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.OccupationalDropdown, "NJMALEE", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkersCompensationDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkersCompensationDropdown, "NJMALER", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.OtherDropdown, "NJ003", SelectOption.Value);
            #endregion

            #region REPORTING INFORMATION, COMMENTS SECTION, & SAVE
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.WorksiteReportingIdTextbox, "95187");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.SuiUnitCodeTextbox, "J91");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PrimaryTextbox, "P1");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.SecondaryTextbox, "2S");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            System.Threading.Thread.Sleep(4000); // THIS IS ABSOLUTELY NECESSARY
            #endregion

            #region WHEN THE CHANGES ARE SAVED, THEN THE GUI IS UPDATED WITH THE CHANGES
            // DETAILS
            UltiPro.Pages.AddChgLocations.Enabled(page => page.LocationCountryLabel);
            UltiPro.Pages.AddChgLocations.Is(page => page.LocationCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(page => page.CodeValue, "innerHTML", "JANALL");
            UltiPro.Pages.AddChgLocations.Is(page => page.DescriptionValueEn, "innerHTML", "Jannette All New Jersey");
            UltiPro.Pages.AddChgLocations.Is(page => page.DescriptionValueCan, "innerHTML", "Jannette NJ DESC CAN1");
            UltiPro.Pages.AddChgLocations.Is(page => page.DescriptionValueGbr, "innerHTML", "Jannette NJ DESC GBR*");
            UltiPro.Pages.AddChgLocations.Is(page => page.DescriptionValueSpn, "innerHTML", "Jannette NJ DESC SPN %^$");
            UltiPro.Pages.AddChgLocations.Is(page => page.DescriptionValueFrn, "innerHTML", "Jannette NJ DESC FRN 456");

            // TRADE NAME
            UltiPro.Pages.AddChgLocations.Is(page => page.TradeNameValueEn, "innerHTML", "Jannette's NJ TRADENAME");
            UltiPro.Pages.AddChgLocations.Is(page => page.TradeNameValueCan, "innerHTML", "JA CAN TRADENAME !@");
            UltiPro.Pages.AddChgLocations.Is(page => page.TradeNameValueGbr, "innerHTML", "JA GBR TRADENAME 12");
            UltiPro.Pages.AddChgLocations.Is(page => page.TradeNameValueSpn, "innerHTML", "JA SPN TRADENAME3");
            UltiPro.Pages.AddChgLocations.Is(page => page.TradeNameValueFrn, "innerHTML", "JA FRN TRADENAME4");
            UltiPro.Pages.AddChgLocations.Is(page => page.GlSegmentValue, "innerHTML", "JANNETTE'S GLS");
            UltiPro.Pages.AddChgLocations.Is(page => page.ImportCodeValue, "innerHTML", "JHIMPORTCO");
            UltiPro.Pages.AddChgLocations.Selected(checkbox => checkbox.InactiveCheckbox);
            UltiPro.Pages.AddChgLocations.Is(page => page.InactiveDateValue, "innerHTML", "05/06/2013");
            UltiPro.Pages.AddChgLocations.Is(page => page.ReportingCategoryValue, "innerHTML", "LOCUSA - USA Rep Cat");

            // PHYSICAL ADDRESS
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressLine1Value, "innerHTML", "NJ Physical Line1");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressLine2Value, "innerHTML", "Physical Address Line 2");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCityValue, "innerHTML", "PhysicalCityNJ");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressStateProvinceValue, "innerHTML", "New Jersey");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressZipPostalCodeValue, "innerHTML", "33333-4444");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCountyValue, "innerHTML", "CORNWALL");

            // CONTACT INFORMATION
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCountryValue, "innerHTML", "Canada");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine1Value, "innerHTML", "5167 NW 87 TERRACE");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine2Value, "innerHTML", "EAGLE RIDGE AT LAUDERHILL");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCityValue, "innerHTML", "LAUDERHILL");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactStateProvinceValue, "innerHTML", "Nova Scotia");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactZipPostalCodeValue, "innerHTML", "R7R 5X5");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCountyValue, "innerHTML", "TORONTO COUNTY");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactNameValue, "innerHTML", "JANNETTE GRACE HAMILTON");
            UltiPro.Pages.AddChgLocations.Is(page => page.MailstopValue, "innerHTML", "1stFLR");
            UltiPro.Pages.AddChgLocations.Is(page => page.DeliveryBarCodeValue, "innerHTML", "8*");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhoneNumberValue, "innerHTML", "(954) 331-7488");
            UltiPro.Pages.AddChgLocations.Is(page => page.ExtensionValue, "innerHTML", "X7488");
            UltiPro.Pages.AddChgLocations.Is(page => page.FaxNumberValue, "innerHTML", "(954) 331-7688");
            UltiPro.Pages.AddChgLocations.Is(page => page.ModemNumberValue, "innerHTML", "(754) 551-4112");

            // TAX INFORMATION
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInStateValue, "innerHTML", "NJSIT - NJ State Income Tax");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInTaxResidentRateValue, "innerHTML", "NJ002 - NJ/NY Waterfront - 2.00%");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInTaxNonResidentRateValue, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.Is(page => page.OccupationalValue, "innerHTML", "NJMALEE - NJ Medical Malpractice EE - $0.00");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkersCompensationValue, "innerHTML", "NJMALER - NJ Medical Malpractice ER - $0.00");
            UltiPro.Pages.AddChgLocations.Is(page => page.OtherValue, "innerHTML", "NJ003 - NJ Catastrophic Illness - $0.00");

            //COMPANIES, REPORTING INFORMATION & COMMENTS
            UltiPro.Pages.AddChgLocations.Is(page => page.CompaniesUsingThisTaxLocationList(1), "innerHTML", "Web Payroll Company");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorksiteReportingIdValue, "innerHTML", "95187");
            UltiPro.Pages.AddChgLocations.Is(page => page.SuiUnitCodeValue, "innerHTML", "J91");
            UltiPro.Pages.AddChgLocations.Is(page => page.PrimaryValue, "innerHTML", "P1");
            UltiPro.Pages.AddChgLocations.Is(page => page.SecondaryValue, "innerHTML", "2S");
            #endregion

            #region WHEN THE CHANGES ARE SAVED, THEN THE DBs ARE UPDATED WITH THE CHANGES
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocGLAcctNo, LocImportCode, LocInactiveDate, LocIsInactive, LocAddressCity, LocAddressCounty, LocAddressLine1, LocAddressLine2, LocAddressLine3, LocAddressLine4, LocAddressState,LocAddressZipcode, LocContactAddressCity, LocContactAddressCountry, LocContactAddressCounty,LocContactAddressLine1, LocContactAddressLine2, LocContactAddressLine3, LocContactAddressLine4, LocContactAddressState, LocContactAddressZipcode, LocBarCode, LocCoBankID, LocContact, LocMailstop, LocPhoneFaxNumber,LocPhoneMainExt, LocPhoneMainNumber, LocPhoneModemNumber, LocReportingCategory, LocReportingUnitNo,LocSUIUnitCode, LocUnitID,LocQEIDCode,LocCMACode, LocPrimaryCommentCode,LocSecondaryCommentCode, LocComments, LocPhoneFaxNumberCountryCode,LocPhoneMainNumberCountryCode, LocPhoneModemNumberCountryCode, LocContractPostSnNoOfGame, LocContractSeasonNoOfGame from location where loccode in ('JANALL')", "LocationBusinessRules/AddLocationsUS_LocnJANALL.xml");
            Database.Company.Verify("SELECT LcpCode, LcpCoID, LcpInactiveDate,LcpIsInactive from loccomp where lcpcode in ('JANALL')", "LocationBusinessRules/AddLocationsUS_LocCompJANALL.xml");
            #endregion
        }
        #endregion

        #region CHECK VIEW LINKS AND RATES WINDOW. DEPENDENT ON TEST 4 (NJ)
        [Test(Order = 5)]
        //[DependsOn("AddLocWithAllFields")] // I WANT THIS TO RUN EVEN IF THE ABOVE FAILS BECAUSE THAT TEST DOES A LOT
        public void CheckLinksAndRatesWindowAdd()
        {
            // GIVEN THAT LOCATION, JANALL, IS SELECTED, WHEN THE View Links and Rates BUTTON IS CLICKED..
            SelectLocationCode("JANALL");
            UltiPro.Pages.AddChgLocations.Click(btn => btn.LinksAndRatesButton);
            
            // THEN THE LINKS AND RATES WINDOW IS DISPLAYED WITH THE FOLLOWING SECTIONS & DATA: ***HEADER***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Enabled(header => header.LinksAndRatesHeader);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(header => header.LinksAndRatesHeader, "innerHTML", UltiPro.Localization.Strings.Links_and_rates);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(header => header.LocalHeader, "innerHTML", UltiPro.Localization.Strings.Local);
            
            // ***WORK-IN COUNTY BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Enabled(legend => legend.WorkInCountyLegend);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.WorkInCountyLegend, "innerHTML", UltiPro.Localization.Strings.Work_hyphen_in_county);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInCountyCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInCountyCodeValue, "innerHTML", "");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInCountyDescriptionLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInCountyDescriptionValue, "innerHTML", "");
            
            // ***WORK-IN TAX RESIDENT RATE BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.WorkInResidentRateLegend, "innerHTML", UltiPro.Localization.Strings.Work_hyphen_in_Tax_hyphen_Resident_Rate.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInResidentCodeLabel, "innerHTML", "Code");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentCodeValue, "innerHTML", "NJ002");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInResidentDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentDescValue, "innerHTML", "NJ/NY Waterfront");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInResidentRateLabel, "innerHTML", UltiPro.Localization.Strings.Resident_Rate.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInResidentNonResRateLabel, "innerHTML", UltiPro.Localization.Strings.Non_hyphen_Resident_rate.ToSentenceCase());
            
            // ***WORK-IN TAX NON-RESIDENT RATE BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.WorkInNonResidentRateLegend, "innerHTML", UltiPro.Localization.Strings.Work_hyphen_in_Tax_hyphen_Non_hyphen_resident_Rate.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInNonResidentCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInNonResidentDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInNonResidentRateLabel, "innerHTML", UltiPro.Localization.Strings.Rate);
            
            // ***WORKERS' COMPENSATION TAX BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.WorkersCompTaxLegend, "innerHTML", UltiPro.Localization.Strings.Workers_apostrophe_compensation_tax);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Selected(radiobtn => radiobtn.WorkersCompTaxCurrentRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxCurrentLabel, "innerHTML", UltiPro.Localization.Strings.Current);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxCurrentCode, "innerHTML", "NJMALER");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxCurrentDescription, "innerHTML", "NJ Medical Malpractice ER");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxRateLabel, "innerHTML", UltiPro.Localization.Strings.Rate);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxCurrentRate, "innerHTML", "$0.00");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.NotSelected(radiobtn => radiobtn.WorkersCompTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxRecommendedLabel, "innerHTML", "Recommended");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxRecommendedCode, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxRecommendedDescription, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxRecommendedRate, "innerHTML", "");
            
            // ***OTHER TAX BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.OtherTaxLegend, "innerHTML", UltiPro.Localization.Strings.Other_Tax.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Selected(radiobtn => radiobtn.OtherTaxCurrentRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentLabel, "innerHTML", UltiPro.Localization.Strings.Current);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentCode, "innerHTML", "NJ003");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OtherTaxDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentDescription, "innerHTML", "NJ Catastrophic Illness");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OtherTaxRateLabel, "innerHTML", UltiPro.Localization.Strings.Rate);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentRate, "innerHTML", "$0.00");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.NotSelected(radiobtn => radiobtn.OtherTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OtherTaxRecommendedLabel, "innerHTML", "Recommended");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedCode, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedDescription, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedRate, "innerHTML", "");
            
            // ***OCCUPATIONAL TAX BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.OccupationalTaxLegend, "innerHTML", UltiPro.Localization.Strings.Occupational_Tax.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Selected(radiobtn => radiobtn.OccupationalTaxCurrentRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxCurrentLabel, "innerHTML", UltiPro.Localization.Strings.Current);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentCode, "innerHTML", "NJMALEE");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentDescription, "innerHTML", "NJ Medical Malpractice EE");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxRateLabel, "innerHTML", UltiPro.Localization.Strings.Rate);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentRate, "innerHTML", "$0.00");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.NotSelected(radiobtn => radiobtn.OccupationalTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxRecommendedLabel, "innerHTML", UltiPro.Localization.Strings.Recommended);
            //UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentRateValue, "innerHTML", "2.00%"); //FAILS ON FF ONLY.  SEES "0.00%" INSTEAD
            //THESE LINES DO NOT WORK ON IE ONLY. SEES " ".  MOVE TO APPROPRIATE SECTION WHEN FIXED
            /* UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInNonResidentCodeValue, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInNonResidentDescValue, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInNonResidentRateValue, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedCode, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedDescription, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedRate, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentNonResRateValue, "innerHTML", "0.00%");*/
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Click(button => button.CancelButton);
        }
        #endregion

        #region GIVEN THAT A DUPLICATE LOCATION CODE IS ENTERED, WHEN THE SYSTEM VALIDATES THAT THE CODE ALREADY EXISTS, THEN THE LOCATION CANNOT BE SAVED. WHEN CANCEL IS HIT, THE PAGE REVERTS TO IT'S ORIGINAL FORM
        [Test(Order = 6)]
        public void AddDuplicate()
        {
            UltiPro.Pages.LocationSummary.ButtonBar.Click(button => button.Add);
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.LocationCountryDropdown, "USA", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.CodeTextbox, "000001");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.DescriptionTextbox.EnglishTextBox, "Jan Duplicate");
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Code must be unique. Code 000001 already exists.");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Cancel);
            UltiPro.Alert.Accept();
        }
        #endregion

        #region GIVEN THAT A LOCATION IS ADDED WITH COUNTY, WORK-IN RESIDENT, WORK-IN NON-RESIDENT, OCCUPATIONAL, WORKER'S COMP & OTHER TAX CODES (AL), WHEN SAVE IS HIT, THEN THE LOCATION IS SAVED
        [Test(Order = 7)]
        //THIS IS SAME AS BELOW BUT AL HAS LESS TAXCODES THAN PA
        public void AddLocWithAllTaxCodesExceptNonResRate()
        {
            UltiPro.Pages.LocationSummary.ButtonBar.Click(button => button.Add);
            SetRequiredFields("USA", "JANALA", "AL All Tax Codes", "Jannette's AL TRADENAME", "AL Physical Line1", "PhysicalCity AL", "AL", "98987", "ALSIT", "Web Payroll Company");
            SetTaxCodes("JEFFERSON", "AL036", "AL003", "ALCNER", "AL023");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            System.Threading.Thread.Sleep(2000);

            //WHEN THE CHANGES ARE SAVED, THEN THE DBs ARE UPDATED WITH THE CHANGES
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocAddressCity, LocAddressCounty, LocAddressLine1, LocAddressState,LocAddressZipcode from location where loccode in ('JANALA') ORDER BY loccode", "LocationBusinessRules/AddLocationsUS_LocJANALA.xml");
            Database.Company.Verify("SELECT LcpCode, LcpCoID, LcpInactiveDate,LcpIsInactive from loccomp where lcpcode in ('JANALA') order by lcpcode", "LocationBusinessRules/AddLocationsUS_LocCompJANALA.xml");
        }
        #endregion

        #region GIVEN THAT A LOCATION IS ADDED WITH COUNTY, WORK-IN RESIDENT, OCCUPATIONAL, WORKER'S COMP & OTHER TAX CODES (PA), WHEN SAVE IS HIT, THEN THE LOCATION IS SAVED
        // THIS TEST IS SPORADICALLY VERY SLOW BECAUSE PA HAS ~18000 TAXCODES; SO RUN LAST.  USUALLY FAILS ON THE FIRST RUN BUT IS NOT CRITICAL AS TEST 7 IS SIMILAR
        [Test(Order = 8)]
        [Timeout(120)]
        public void AddLocWithAllTaxCodesExceptNonResRatePa()
        {
            UltiPro.Pages.LocationSummary.ButtonBar.Click(button => button.Add);
            SetRequiredFields("USA", "JANPA2", "PA All Tax Codes", "Jannette's PA TRADENAME", "PA Physical Line1", "PhysicalCity PA", "NY", "108233214", "PASIT", "Web Payroll Company");
            SetTaxCodesWithNoNonResRate("ALLEGHENY", "PA100001", "PA100027", "PAPITTER", "PA100071");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            System.Threading.Thread.Sleep(30000);

            //WHEN THE CHANGES ARE SAVED, THEN THE DBs ARE UPDATED WITH THE CHANGES
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocAddressCity, LocAddressLine1, LocAddressLine2, LocAddressState,LocAddressZipcode from location where loccode in ('JANPA2') ORDER BY loccode", "LocationBusinessRules/AddLocationsUS_LocJANPA2.xml");
            Database.Company.Verify("SELECT LcpCode, LcpCoID, LcpInactiveDate,LcpIsInactive from loccomp where lcpcode in ('JANPA2') order by lcpcode", "LocationBusinessRules/AddLocationsUS_LocCompJANPA2.xml");
        }
        #endregion
    }
}